<template>
  <el-dialog v-model="showForm" title="Tips" width="500">
    <span>This is a message</span>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="showForm = false">Cancel</el-button>
        <el-button type="primary" @click="showForm = false">Confirm</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import { ref, reactive } from "vue"
import { getFields } from "@/api/pub/dataSource"
//弹窗开关绑定
const showForm = ref(false)
const dataId = reactive({
  id: "",
})
//字段数据
const fields = ref([])
//初始化数据
const init = (id?: number) => {
  showForm.value = true
  dataId.id = ""
  //查询单条数据
  if (id) {
    getDataSourceFields(id)
  }
}

//查询单条数据
const getDataSourceFields = (id: number) => {
  getFields(id).then((res) => {
    Object.assign(fields, res.data)
    // console.log(fields.value)
  })
}
//加载
defineExpose({
  init,
})
</script>

<style scoped lang="scss"></style>
